<?php
namespace Home\Controller;
use Think\Controller;
class Player1Controller extends BaseController {
    public function index(){
        $user_id = session('user_id');
        print_r($user_id);die;
        $map = array('player_id'=>$user_id);
        $his_games = M('PlayerGame')->where($map)->order('last_play_time desc')->limit(20)->select();
        $Game = M('Game');
        if (!empty($his_games)){
            $his_list = array();
            foreach ($his_games as $key=>$item) {
                $game = $Game->where(array('id'=>$item['game_id'],'status'=>1))->find();
                if (!empty($game)) {
                    $data = array(
                        'title' => $game['name'],
                        'subtitle' => $game['sub_title'],
                        'img'=>'../appc/Uploads/'.$game['icon'],
                        'url' => U('Index/detail', array('id'=>$game['id']))
                    );
                    $his_list[] = $data;
                }
            }
            $this->assign('his',$his_list);
        }

        $user_agent = $_SERVER['HTTP_USER_AGENT'];
        if (strpos($user_agent, 'MicroMessenger') === false) {
            $is_wx = 0;
        }else{
            $is_wx = 1;
        }
        $this->assign('is_wx',$is_wx);

        $this->display();
    }
    
}